
define([ "Zepto", "underscore", "Backbone", "Handlebars",
  "views/university/universitylistitemview" ], function($, _, Backbone, Handlebars, UniversityListItemView) {


	var UniversityListView = Backbone.View.extend({


		initialize : function() {

			this.model.bind("reset", this.render, this);

		},

		render : function(eventName) {
			  $(this.el).empty();
			  _.each(this.model.models, function(university) {
				 // alert('university: ' + university.get('immagine').url);
				  $(this.el).append(new UniversityListItemView({
				  	tagName : 'a', //Crea un nuovo tag <a> invece di usarne uno già presente nel DOM
					attributes : {
						'href' : '#facultylist/'+university.get('objectId')
					},
					model : university
				  }).render().el);
			  }, this);
			  return this;
		},

		events : {
			'touchstart .list-item' : 'over',
			'touchend .list-item' : 'left',
			'touchcancel .list-item' : 'left',
		},

		over : function(event) {
			$(event.currentTarget).addClass('fake-active');
		},

		left : function(event) {
			$(event.currentTarget).removeClass('fake-active');
		}
	});


	return UniversityListView;

});